<%#
    Auth: Wen
    Version: V1.0
    Data: 2019.8.20
    Function:
%>
<%+header%>
<html>
    <head>
    <meta charset="utf-8">
    <title>Wen</title>

    <script type="text/javascript">
    var manualTemp = "";
    function checkLeave()
    {
        return "Leave?";
    }
    function ManualLog(tmp, str)
    {
        tmp = tmp + str + "\n"; 
        return tmp;
    }
    var XHR1 = new XHR();
    function EnterManualMode()
    {
		document.getElementById("warming").innerHTML = "";
        XHR1.post('<%=controller%>admin/ACU_Antenna/manual', {token:'<%=token%>', step: '10'}, function(x){
            //如果进入测试模式成功
            if(x.responseText.includes("COMMAND OK") == true)
            {
                document.getElementById("warming").innerHTML = "<%:Title: Enter manual mode success!%>";
                manualTemp = ManualLog(manualTemp, "Enter manual mode success!");
            }
            else
            {
                document.getElementById("warming").innerHTML = "Title:" + x.responseText;
                manualTemp = ManualLog(manualTemp, x.responseText);
            }
            document.getElementById("manualLog").value = manualTemp;
        })
    }
    function ExitManualMode()
    {
		document.getElementById("warming").innerHTML = "";
        XHR1.post('<%=controller%>admin/ACU_Antenna/manual', {token:'<%=token%>', step: '11'}, function(x){
            //如果退出测试模式成功
            if(x.responseText.includes("COMMAND OK") == true)
            {
                document.getElementById("warming").innerHTML = "<%:Title: Exit manual mode success!%>";
                manualTemp = ManualLog(manualTemp, "Exit manual mode success!");
            }
            else
            {
                document.getElementById("warming").innerHTML = "Title:" + x.responseText;
                manualTemp = ManualLog(manualTemp, x.responseText);
            }
            document.getElementById("manualLog").value = manualTemp;
        })
    }
	
    function ManualSearch()
    {
		document.getElementById("warming").innerHTML = "";
        var manualItems = new Object();
        manualItems.direction = document.getElementById("direction").value;
        manualItems.speed = document.getElementById("speed").value;
        manualItems.angle = document.getElementById("angle").value;
		
        var select = document.getElementById("direction");
        var i = select.selectedIndex;
        var options = select.options;
        var text1 = options[i].text;
		
        XHR1.post('<%=controller%>admin/ACU_Antenna/manualItems', {token:'<%=token%>', 
            para1:manualItems.direction,
            para2:manualItems.speed,
            para3:manualItems.angle}, function(x){
            
            if(x.responseText.includes("COMMAND OK") == true)
            {
                document.getElementById("warming").innerHTML = "<%:Title: Operation success!%>";
                manualTemp = ManualLog(manualTemp,  text1 + ": " + manualItems.speed + ","
                    + manualItems.angle);
            }
            else
            {
                document.getElementById("warming").innerHTML = "Title:" + x.responseText;
                manualTemp = ManualLog(manualTemp, x.responseText);
            }
            document.getElementById("manualLog").value = manualTemp;
        })
    }
	
    function ClearManualLog()
    {
        document.getElementById("manualLog").value = "";
        manualTemp = "";
    }
	
    </script>
    </head>
    <body onbeforeunload="return checkLeave()">
        <p style="color:red;" id="warming"></p>
        <fieldset class="cbi-section-node">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                <i class="icon-align-justify"></i>
                </span>
                
                <h5><%:Manual Operation%></h5>
                <div class="pull-right">
                    <div style="margin-top: 4px; margin-bottom: 0px;margin-right:10px">
                    <input class="btn btn-success" type="button"  id="enter" value="<%:Enter Manual Mode%>" onclick="EnterManualMode()">
                    <input class="btn btn-info" type="button"  id="exit" value="<%:Exit Manual Mode%>" onclick="ExitManualMode()">
                    <i class="icon"></i>
                    </div>
                </div>
            </div>

            <div class="widget-content nopadding">
                <table width="100%" cellspacing="10">
                    <tr><td width="15%"><%:Direction Of Rotation%></td><td>
                        <select class="cbi-input-select" data-update="change" id="direction" size="1">
                        <option value="-1" selected="selected"><%:All Stop%></option>
                        <option value="0"><%:Azimuth Clockwise%></option>
                        <option value="1"><%:Azimuth Counterclockwise%></option>
                        <option value="2"><%:Pitch Up%></option>
                        <option value="3"><%:Pitch Down%></option>
                        <option value="4"><%:Rx Pol Clockwise%></option>
                        <option value="5"><%:Rx Pol Counterclockwise%></option>
                        <option value="6"><%:Tx Pol Clockwise%></option>
                        <option value="7"><%:Tx Pol Counterclockwise%></option>
                        <option value="8"><%:Roll Clockwise%></option>
                        <option value="9"><%:Roll Counterclockwise%></option>
                        </select>
                    </td></tr>
                    <tr><td width="15%"><%:Speed Of Rotation%></td><td><input id="speed" type="number" min="0.0" max="20" step="0.1" class="cbi-input-text"/>
                        <div class="cbi-value-description">
                            <span class="cbi-value-helpicon">
                            <img src="/luci-static/resources/cbi/help.gif" alt="help" />
                            </span>
                            <%:Range%>:0~20.0&#176/s
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Angle Of Rotation%></td><td><input id="angle" type="number" min="0.0" max="90" step="0.1" class="cbi-input-text"/>
                        <div class="cbi-value-description">
                            <span class="cbi-value-helpicon">
                            <img src="/luci-static/resources/cbi/help.gif" alt="help" />
                            </span>
                            <%:Range%>:0~90.0&#176
                        </div>
                    </td></tr>
                </table>
            </div>
        </div>
        </fieldset>	
        
        <div style="margin-top:15px;  margin-left:250px;">
            <input class="btn" style="width:100px; height:30px;" id="items" type="button" value="<%:DONE%>" onclick="ManualSearch()">
        </div>
		
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                <i class="icon-align-justify"></i>
                </span>
                <h5><%:Manual Log%></h5>
					<i class="icon" ></i>
                <div class="pull-right">
                    <div style="margin-top: 4px; margin-bottom: 0px;margin-right: 4px">		
                        <input class="btn btn-success" type="button" id="clearLog" value="<%:Clear Log%>" onclick="ClearManualLog()">
                        <i class="icon"></i>
                    </div>
                </div>
            </div>
            <div class="widget-content nopadding">
                <div>
                <textarea style="width:100%" readonly="readonly" cols="100" rows="20" id="manualLog">
                </textarea>
                </div>
            </div>
        </div>
    </body>
</html>
<%+footer%>